#pragma once

#include <iostream>


class Handler{
  public:
  void operator()(int x, int y, char op, int res)
  {
      switch(op){
        case '+': res = x + y;
          break;
        case '-': res = x - y;
          break;
        case '*': res = x * y;
          break;
        case '/': if(y == 0){
                    std::cerr << "div zero" << std::endl;
                  }
                  else res = x / y;
          break; 
        case '%': if(y == 0){ 
                    std::cerr << "mod zero" << std::endl;
                  }
                  else res = x % y;
          break;
        default:
          break;
      } 
      printf("%2d %c %2d = %d\n", x, op, y, res);
  }
};

class Task{
  private:
    int x;
    int y;
    char op;
    Handler handler;
  public:
    Task(int _x, int _y, char _op):x(_x), y(_y), op(_op)
    {}

    Task(){}
    
    void Run(int res = -1)
    {
      handler(x, y, op, res);
    }
    
    ~Task(){}
};
